using System;
using Rubikev.Common.DependencyInjection;
using StructureMap.Configuration.DSL;

namespace Rubikev.StructureMap
{
   /// <summary>
   /// Adapts an IRegister to a StructureMap Registry type
   /// </summary>
   public class RegisterAdapter : Registry
   {
      /// <summary>
      /// Registers the <paramref name="register"/> with StructureMap
      /// </summary>
      /// <param name="register">The register to register</param>
      /// <exception cref="ArgumentNullException">If the <paramref name="register"/> is null</exception>
      public RegisterAdapter(IRegister register)
      {
         if (register == null)
         {
            throw new ArgumentNullException("register", "Cannot register a null register");
         }

         register.Register();
      }
   }
}